<?php
namespace kernel\library;

class Route
{
    public static $routeList = [];
    public static function match(array $methods, string $uri, $action = null, array $middleware = []){
        self::$routeList[$uri] = [
            $methods,
            $action,
            $middleware
        ];
    }
    
    /**
     * 获取路由
     * @param string $uri
     * @return array|mixed
     */
    public static function get(string $uri){
        return self::$routeList[$uri] ?? Error::setError("路由地址不存在", 404);
    }
    
    /**
     * 获取全部路由
     * @return array
     */
    public static function getAll(){
        return self::$routeList;
    }
    
    /**
     * 情况路由
     */
    public static function clean(){
        self::$routeList = [];
    }
}

